package me.keiwu.user.domain;

import lombok.Data;
import org.hibernate.annotations.ColumnDefault;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Created by kei on 25/11/2017.
 */
@Data
@Entity
@Table(uniqueConstraints = {
        @UniqueConstraint(name = "idx_user_id_item_id", columnNames = {"userId", "itemId"}),
})
public class UserItem extends AbstractBaseEntity {

    @Id
    @GeneratedValue
    private Long id;

    private Long userId;

    private Integer itemId;

    // 冗余字段
    @ColumnDefault("0")
    @Column(nullable = false)
    private Integer itemType = 0;

}
